{% extends "blog/base.html" %}
{% block title %}搜索{% endblock %}
{% block content %}
{% if query %}
<h1>包含“{{ query }}"的搜索结果如下：</h1>
<h3>
    {% with results.count as total_results %}
    Found{{ total_results }} result{{ total_results|pluralize }}
    {% endwith %}
</h3
{% for post in results %}
<h4>
    <a href="{{ post.get_absolute_url }}">{{ post.title }}</a>
</h4>
    {{ post.body|truncatewords:5 }}
{% empty %}
    <p>没有任何结果</p>
    {% endfor %}
<p>
    <a href="{% url "blog:post_search" %}">再搜索</a>
</p>
            {% else %}
<h1>搜索从post</h1>
<form action="." method="get">
    {{ form.as_p }}
    <input type="submit" value="Search">
</form>
{%  endif %}
{% endblock %}